package uk.ac.glasgow.demosocs.impl.ui;

import uk.ac.glasgow.clui.SystemCommand;
import uk.ac.glasgow.clui.SystemCommandException;
import uk.ac.glasgow.demosocs.VotingSystem;

public class UsageCommand extends SystemCommand<VotingSystem> {

	enum Choice {
		create, user, election, edit, elections, nominate, accept, nominations, cast, publish
	};

	public UsageCommand(VotingSystem facade) {
		super(facade);
	}

	@Override
	public String processCommand(String[] arguments)
			throws SystemCommandException {

		if (arguments.length == 0) {
			return "Correct usage: usage/u <command>\n";
		}

		String myChoice = arguments[0];
		Choice ch = null;

		try {

			ch = Choice.valueOf(myChoice);

			if (Choice.valueOf(myChoice) != null) {

				switch (ch) {
				case create:
					System.out.println("For 'First Past The Post': <name> FPTP <nomination day> <nomination time> <start day> <start time> <stop day> <stop time> <electorate ID>");
					System.out.println("For a Referendum: <name> REF <startDate> <startTime> <endDate> <endTime> <Question> <elecID>");
					System.out.println("For an Alternative Vote: ");
					break;
				case user:
					System.out.println("<guid> <password>");
					break;
				case election:
					System.out.println("<election: EID>");
					break;
				case edit:
					System.out
							.println("<nomination day> <nomination time> <start day> <start time> <stop day> <stop time> <electorate ID>");
					break;
				case elections:
					System.out.println("No usage: List all elections.");
					break;
				case nominate:
					System.out.println("<candidate: GUID>");
					break;
				case accept:
					System.out
							.println("No usage: Accept a nomination for the currently selected election.");
					break;
				case nominations:
					System.out
							.println("No usage: List all nominations for the currently selected user.");
					break;
				case cast:
					System.out.println("<candidate: GUID>");
					break;
				case publish:
					System.out
							.println("No usage: Publish the results of the currently selected election.");
					break;
				}

			} else
				System.out.println("No usage provided");
			return "\n";
		} catch (IllegalArgumentException e) {
			System.out.println("Command does not exit, please try again");
			return "\n";
		}
	}
}
